<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <title>Euler函数-φ的计算</title>
    <script>
        function mygcd(a, b) {
            if (b) while ((a %= b) && (b %= a));
            return a + b;
        }


        function solve(N) {
            let cnt = 0;
            document.write("区间中符合条件的数有(输出格式:20/line):<br>")
            for (let i = 1; i < N; ++i) {
                if (mygcd(N, i) === 1) {
                    ++cnt;
                    document.write(i + " ");
                    if (cnt % 20 === 0) document.write("<br>"); // 每输出20个数换一行
                }
            }
            document.write("<br>")
            return cnt;
        }
    </script>
</head>

<body>
    <h3>p=19,q=23,对N=p*q计算N的φ值</h3>
    <hr>
    <h3>输出与N(=p*q)互素的全部整数</h3>
    <hr>
    <h3>显示φ(N)</h3>
    <script>
        let p = 19, q = 23;
        let N = p * q;

        // 计算φ(N)并输出与N互素的所有整数
        let nums = solve(N);

        document.write("<br>N=p*q的Euler-φ函数=" + nums);
    </script>
</body>

</html>